package cn.com.product.bean;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import cn.com.product.util.JDBCConnection;

public class CategoryBean {
	public List<Category> getCategorys(){
		List<Category> list = new ArrayList<Category>();
		Connection con = JDBCConnection.getCon();
		String sql = "select * from category";
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery(sql);
			while(rs.next()){
				Category c = new Category();
				c.setId(rs.getString(1));
				c.setName(rs.getString(2));
				c.setDescn(rs.getString(3));
				list.add(c);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return list;
	}
}